package servlet.huwenyao;

import net.sf.json.JSONObject;
import pojo.Evaluate;
import pojo.Order;
import service.EvaluateService;
import service.OrderService;
import service.impl.EvaluateServiceImpl;
import service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

/**
 *
 */
@WebServlet(value = "/InsertEvaServlet")
public class InsertEvaServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //解决乱码
        request.setCharacterEncoding("UTF-8");
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/json;charset=utf-8");
        //获取修改页面的数据
        String wareId = request.getParameter("wareId");
        String consumerAccount = request.getParameter("consumerAccount");
        String score = request.getParameter("score");
        String img = request.getParameter("img");
        String desc = request.getParameter("desc");
        Evaluate evaluate=new Evaluate();
        evaluate.setWareId(Integer.parseInt(wareId));
        evaluate.setConsumerId(Integer.parseInt(consumerAccount));
        evaluate.setEvaluateScore(Integer.parseInt(score));
        evaluate.setEvaluatePhoto(img);
        evaluate.setEvaluateDescribe(desc);
        EvaluateService es = new EvaluateServiceImpl();
        int bo=es.InseEvaluate(evaluate);
        JSONObject json=new JSONObject();
        if(bo>0){
            json.put("msg","新增成功");
        }else{
            json.put("msg","新增失败");
        }
        PrintWriter out = response.getWriter();
        out.print(json);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
